<?php
    /* 书评详情页
     * 可查看书评，可回复书评
     * @author huangchuting
     * @time 2020.6.5
     * @param $reviewId
     * */
    require_once 'header.php';
    require_once '../inc/review.php';
    require_once '../inc/user.php';
    require_once '../inc/reply.php';
    require_once '../inc/section.php';
    
    $reviewId=$_GET["reviewId"];
    $current_user=$_SESSION["CURRENT_USER"];
    $uId=$current_user["uId"];    
    $review=getReviewId($reviewId);
    $title=$review["title"];
    $content=$review["content"];
    $labelId=$review["labelId"];
    $reviewtime=$review["reviewtime"];
    $bookId=$review["bookId"];
    $reviewUId=$review["uId"];
    $reviewER=getUserId($reviewUId);
    $uIdReview=$reviewER["uId"];
    $uName=$reviewER["uName"];
    $uhead=$reviewER["head"];
    $sex=$reviewER["sex"];
    $good=$review["good"];
    $replyCount=replyCountRId($reviewId);
    if ($labelId==1)
    {
        $labelName="";
    }
    else
    {
        $label=getLabelId($labelId);
        $labelName=$label["label"];
    }
    
    $zan=getReviewZanUId($reviewId, $uId);
    $zanId=$zan["zanId"];

?>
<html>
	<head>
		<!-- <meta http-equiv="refresh" content="30"> -->
		<base target="_blank" />
		<meta charset="UTF-8">
		<title>书评详情页-阅读记</title>
	</head>
		<link rel="stylesheet" href="../css/review.css">
		<script type="text/javascript" src=../inc/jquery-2.1.1.min.js></script>
		<script src="../script/review.js"></script>
	<body>
		<div class="DIV">
			<div class="main">
			<div class="host" id="host"  >
						<div class="reviewEr">
							<div class="reviewImg">
								<img alt="" src="../image/head/<?php echo $uhead ;?>">
							</div>
							<div class="reviewErNew">
									<span>用户名：<a href="reviewWriter.php?reviewUId=<?php echo $reviewUId ;?>" target="_Blank"><?php echo $uName ;?></a></span><br>
									<span>性别：<?php echo $sex ;?></span><br>
							</div>
						
						</div><!-- /reviewEr -->
						<div class="review">
								<div class="title">
									<span class="tips">标题：</span><span class="titleNew"><?php echo $title; ?></span>
								</div><br>
								<div class="content">
									<span class="tips">内容：</span>
										<span >
									 		<?php echo $content; ?>
										</span>
								</div><br><!-- /content -->
								<div class="label">
									<span class="tips" >标签：</span>
									<span class="label"><?php echo $labelName?></span>
								</div><br>
								<div class="time">
									<span class="tips" >发布时间：</span>
									<span><?php echo $reviewtime?></span>
									
									<?php 
									   if ($uId==$uIdReview) {
									       $showDel="";
									       $showDel.=<<<html
									<button type="button" onclick="ReviewDel('$reviewId','$bookId')">删除</button>
									<button type="button" onclick="ReviewUp('$reviewId','$bookId')">修改</button>
html;
                                            echo $showDel;
									   }
									?>


								</div><br>

						</div><!-- /review -->
				</div><!-- /host -->
				
				<div class="opera">
						<div class="operaSort">
							<div class="doreplyDIV">
							 
   							 <input type="hidden" id="reviewId" value="<?php echo $reviewId?>" />
								<button id="doreply" onclick="reply()"></button>
								<span id="replyCount"><?php echo $replyCount; ?></span>
							</div>
						</div>
						<div class="operaSort" >
							<div class="dolikeDIV" id="dolikeDIV">
								<input type="hidden" id="uId" value="<?php echo $uId?>" />
								<?php 
								       $showZan="";
								       if (!empty($zan)) 
								       {  
								          $showZan.=<<<html
                                        
								        <button id="dolike" onclick="zanDel()"></button>
								        <span id="zan">$good</span>
html;
								          echo $showZan;
								       }
								       else 
								       {
								           $showZan.=<<<html
								           <button id="donolike" onclick="zan()"></button>
								           <span id="zan">$good</span>
html;
								           echo $showZan;
								       }
								           
								           
								?>
								
							</div>
						</div>
						<div class="writeReply" id="writeReply">
							<span><?php echo "" ?></span>
						</div>
				</div><!-- /opera -->

				<div class="replys" id="replys">
						<?php 
						      $replys=getReplyRId($reviewId);
						      $showReply="";
						      for ( $i=0; $i<count($replys); $i++)
						      {   
						          $replyId=$replys["$i"]["replyId"];
						          $replyUId=$replys["$i"]["uId"];
						          $replyContent=$replys["$i"]["content"];
						          $replytime=$replys["$i"]["replytime"];
						          $user=getUserId($replyUId);
						          $uName=$user["uName"];
						          $replyUhead=$user["head"];
						          $showReply.=<<<html
                                   <div class="reply">
                                        <div class="replyer">
                                            <img src="../image/head/$replyUhead">
                                            <span>$uName</span>
                                        </div><br>
                                        <div class="replyNew">
                                              <span>$replyContent</span> <br>
                                               
                                        </div><br>
                                        <div class="replyTimeDIV">
                                            <span class="replyTime">发布时间：$replytime</span>
html;
						          
						          if($uId==$uIdReview){
                                                  $showReply.=<<<html
                                                    <button onclick="ReplyDel('$reviewId','$replyId')">删除</button>
html;
                                                    }
                                            
                                            $showReply.=<<<html
                                       </div><br>
                                   </div>
html;
						      }
						          echo $showReply;
						?>
					
					
				</div><!--  /replys-->
				
			</div><!-- main -->
			
		</div><!-- /DIV -->
		<?php require_once 'footer.php';?>
	</body>
</html>